<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.global.js"></script>
</head>
<body>
    <div id="app"></div>
    
    <script>
        const Son = {
            template:`
            <h4>我是牛魔:{{age}}</h4>
            `,
            props:["age"],
            beforeCreate() {
                console.log("beforeCreate")
            },
            created(){
                console.log("created");
            },
            beforeMount(){
                console.log("beforeMount");
            },
            mounted(){
                console.log("mounted");
            },
            beforeUpdate(){
                console.log("beforeUpdate");
            },
            updated(){
                console.log("updated");
            },
            beforeUnmount(){
                console.log("beforeUnmount");
            },
            unmounted(){
                console.log("unmounted");
            }
        }
        Vue.createApp({
            template:`
            <h3>我是酬宾</h3>
            <son v-bind:age="age" v-if="showSon"></son>
            <button v-on:click="addAge">更新数据</button>
            <button v-on:click="switchShowSon">显隐子组件</button>
            `,
            components:{
                Son
            },
            data(){
                return {
                    age:1,
                    showSon:true
                }
            },
            methods:{
                addAge(){
                    this.age++
                },
                switchShowSon(){
                    this.showSon = !this.showSon
                }
            }
        }).mount("#app")
    </script>
</body>
</html>